package com.baizhi.controller;

import com.baizhi.entity.CmfzResource;
import com.baizhi.service.CmfzResourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.lang.reflect.Array;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/4/20 0020.
 */
@Controller
@RequestMapping("/resource")
public class CmfzResourceController {
    @Autowired
    private CmfzResourceService cmfzResourceService;
    private Logger logger= LoggerFactory.getLogger(CmfzResourceController.class);

    @RequestMapping("/queryResource")
    public @ResponseBody List<CmfzResource> queryResource(){
        List<CmfzResource> cmfzResources = cmfzResourceService.queryResource();
        return cmfzResources;
    }

    @RequestMapping("/updateRoleResource")
    public @ResponseBody Map updateRoleResource(String updateroleName, int[] ids){
        Map map = cmfzResourceService.updateRoleResource(updateroleName, ids);
        return map;
    }

    @RequestMapping("/showSelected")
    public @ResponseBody List<Integer> showSelected(HttpSession session,String roleName){
        logger.debug("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        List<Integer> integers = cmfzResourceService.showSelected(session,roleName);
        logger.debug("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@获取的数据是：{}",integers);
        return integers;
    }
}
